#include "interface.h"
#include "bedroom1.h"
#include "bedroom2.h" // 添加 bedroom2 头文件
#include "bedroom3.h" // 添加 bedroom3 头文件
#include <QVBoxLayout>
#include <QPalette>

interface::interface(QWidget *parent)
    : QWidget(parent)
{
    setWindowTitle("智能家居系统");
    setMinimumSize(800, 600); // 设置最小窗口大小

    createButtons(); // 创建按钮

    // 设置布局
    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->addWidget(bedroom1Button);
    layout->addWidget(bedroom2Button);
    layout->addWidget(bedroom3Button);
    layout->setAlignment(Qt::AlignTop); // 将按钮对齐到顶部
    setLayout(layout);

    // 设置背景颜色
    QPalette palette = this->palette();
    palette.setColor(QPalette::Window, QColor(240, 240, 240)); // 设置背景为浅灰色
    this->setPalette(palette);
}

void interface::createButtons()
{
    // 创建按钮并设置样式
    bedroom1Button = new QPushButton("卧室 1", this);
    bedroom1Button->setStyleSheet("background-color: lightblue; font-size: 18px; padding: 15px; border-radius: 10px; border: 2px solid blue;");
    connect(bedroom1Button, &QPushButton::clicked, this, &interface::showBedroom1);

    bedroom2Button = new QPushButton("卧室 2", this);
    bedroom2Button->setStyleSheet("background-color: lightgreen; font-size: 18px; padding: 15px; border-radius: 10px; border: 2px solid green;");
    connect(bedroom2Button, &QPushButton::clicked, this, &interface::showBedroom2);

    bedroom3Button = new QPushButton("卧室 3", this);
    bedroom3Button->setStyleSheet("background-color: lightcoral; font-size: 18px; padding: 15px; border-radius: 10px; border: 2px solid red;");
    connect(bedroom3Button, &QPushButton::clicked, this, &interface::showBedroom3);
}

void interface::showBedroom1()
{
    bedroom1 *bedroom1Widget = new bedroom1();
    bedroom1Widget->setMinimumSize(800, 600);
    bedroom1Widget->show(); // 显示卧室 1 界面
}

void interface::showBedroom2()
{
    bedroom2 *bedroom2Widget = new bedroom2();
    bedroom2Widget->setMinimumSize(800, 600);
    bedroom2Widget->show(); // 显示卧室 2 界面
}

void interface::showBedroom3()
{
    bedroom3 *bedroom3Widget = new bedroom3();
    bedroom3Widget->setMinimumSize(800, 600);
    bedroom3Widget->show(); // 显示卧室 3 界面
}
